package pattern;

/**
 * Created with IntelliJ IDEA.
 * Description:懒汉模式改进版1-同步方式
 * User: bjc
 * Date: 2025-08-24
 * Time: 21:43
 */

class SingletonLazy1 {
    private static SingletonLazy1 instance;
    private SingletonLazy1() {}
    /*public static  SingletonLazy1 getInstance() {
        synchronized (SingletonLazy1.class){
            if(instance == null){
                instance = new SingletonLazy1();
            }
        }
        return instance;
    }*/
    public static synchronized SingletonLazy1 getInstance() {
        if(instance == null){
            instance = new SingletonLazy1();
        }
        return instance;
    }
}



public class Test3 {
}
